Skip to content

Fix RequestNotRead crash in XGlean hook for multipart file uploads#143

Merged
steve-calvert-glean merged 1 commit into
mainfrom
fix/x-glean-hook-multipart-upload
Apr 20, 2026
Merged

Fix RequestNotRead crash in XGlean hook for multipart file uploads#143
steve-calvert-glean merged 1 commit into
mainfrom
fix/x-glean-hook-multipart-upload

Conversation

@steve-calvert-glean
Copy link
Copy Markdown
Contributor

Summary

  • Fixes httpx.RequestNotRead crash when calling upload_files / upload_files_async (GitHub issue upload_files()/upload_files_async() raises httpx.RequestNotRead #136)
  • The XGlean hook was reconstructing the entire httpx.Request to add headers, which accessed request.content — a property that raises RequestNotRead on multipart (streaming) bodies
  • Fix: mutate request.headers in place instead of reconstructing the request

Test plan

  • All 15 existing + new tests pass (poetry run pytest tests/test_x_glean_hook.py)
  • New test test_handles_multipart_streaming_request reproduces the exact crash scenario
  • Verified old code raises RequestNotRead, new code does not
  • Confirmed x_glean.py and test file are not Speakeasy-managed (safe from regeneration)

🤖 Generated with Claude Code

The XGlean hook reconstructed the httpx.Request to add headers, which
accessed request.content — a property that raises RequestNotRead on
streaming (multipart) bodies. This broke upload_files and
upload_files_async. Mutate headers in place instead.

Fixes GitHub issue #136

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner April 20, 2026 16:09
@steve-calvert-glean steve-calvert-glean merged commit 8ce2c8e into main Apr 20, 2026
3 checks passed
@steve-calvert-glean steve-calvert-glean deleted the fix/x-glean-hook-multipart-upload branch April 20, 2026 16:13
@steve-calvert-glean steve-calvert-glean added the bug Something isn't working label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants